$(function(){
	var childFormHTML="";
	var childList=[];
	/* 查询我的宝宝列表 */
	ym.ajax({
		url: "/userChild/getUserChild",
		success: function (data) {
		  if(data.obj){
		   	childList=data.obj;
		   	if(data.obj.length > 0||data.obj!==null){
		   		for (var i = 0; i < data.obj.length; i++) {
			   		childFormHTML+="<li curIndex='"+data.obj[i].childId+"'>"+
				  				   "<a href='javascript:void(0)'>"+
				  				   "<div class='baby-desc'>"+
				  				   "<div class='baby-head-img'><p class='head-img'><img src='"+data.obj[i].childHeadimgurl+"'></p></div>"+
				  				   "<div class='baby-form'>"+
				  				   "<p class='baby-name'>"+data.obj[i].childRealname+"</p>"+
				  				   "<p class='baby-age'>"+data.obj[i].childBirthday+"</p>"+
				  			       "</div>"+
				  				   "</div>"+
				  				   "<p><i class='am-icon-angle-right'></i></p>"+
				  	               "</a>"+
				                   "</li>";
			   		
			   	}
			   	$('.child-form').append(childFormHTML);
		   	}else{
		   		childFormHTML = '<li class="am-text-center" style="padding:1rem">您暂时还没有添加宝宝哦!</li>';
				$('.child-form').append(childFormHTML);
		   	}
		   	
		   }
		}
	});
	/* 查看宝宝详情 */
	window.setTimeout(function(){
		$('.child-form li').click(function(){
			var curIndex=$(this).attr('curIndex');
			for (var i = 0; i < childList.length; i++) {
				if(childList[i].childId==curIndex){
					sessionStorage.setItem('curData',JSON.stringify(childList[i]));
					window.location.href='../html/childrenForm.html';
				}
			}
		})
	},1500)
	
})